#ifndef __AOTTOOL_H__
#define __AOTTOOL_H__
#include "AoTObject.h"
#include "AoTMemoryManager.h"
#include "AoTParticleSystem.h"
enum ToolType
{
	SPEED_UP =1,
	GET_MONEY=2,
	CD_ACCELERATE=3,
	LEVEL_UP=4
};
enum ToolState
{
	BEFORE_PICK=1,
	AFTER_PICK=2
};

class AoTTool :public AoTObject
{
public:
	AoTParticle *toolParticle;
	Ogre::SceneNode *toolParticleNode;
	Ogre::String toolName;
	Ogre::String meshName;
	ToolState toolState;
	int toolParticleIndex_show;
	int toolParticleIndex_get;
	int toolsoundIndex_get;
	int toolsoundIndex_use;
	float toolGetTime;
	int toolBuffIndex;
	float lastTime;
	int levelUp;
	int toolType;
	float speedUp;
	int money;
	float CDAccelerate;
	float positionCheck;
public:
	AoTTool()
	{
		toolGetTime=3.0;
	};
	void update(float time);

};

class AoTToolInfo
{
public:
	Ogre::String toolName;
	Ogre::String meshName;
	int toolParticleIndex_show;
	int toolParticleIndex_get;
	int toolsoundIndex_get;
	int toolsoundIndex_use;
	int toolBuffIndex;
	int toolType;
	int levelUp;
	float speedUp;
	int money;
	float lastTime;
	float CDAccelerate;
public:
	void load(lua_State* l, int i);
};

class AoTToolManager
{
public:
	AoTMemoryManager<AoTTool>* toolManager;
	SceneManager* sm;
	AoTToolInfo*	toolList;
	int toolListLength;
	float refresh;

public:
	AoTToolManager(SceneManager* sm,int maxTool);
	
	~AoTToolManager()
	{
		for(int i=0;i<toolManager->total;i++)
		{
			toolManager->memory[i].toolParticle->remove(sm);
		}
		for(int i = 0; i < toolManager->total; i++)
		{
			toolManager->memory[i].toolParticle->remove(sm);
		}
		delete toolManager;
	}
	void load(String AoTToolResource);
	void update(float time);
	AoTTool* get();
	void init();
	void release(int i);
	void createTool();
	AoTTool* get(int index)
	{
		return &toolManager->memory[index];
	}
};
 
#endif
